import request from '@/utils/request'
// 封装teacher模块的CRUD的异步请求的函数
export default{
  // 7.编辑讲师
  update(teacher) {
    return request({
      url: `/admin/edu/teacher/updateById`,
      method: 'PUT',
      data: teacher
    })
  },
  // 6.编辑讲师回显数据，先根据id查询讲师
  getById(id) {
    return request({
      url: `/admin/edu/teacher/getById/${id}`,
      method: 'GET'
    })
  },
  // 5.新增讲师
  save(teacher) {
    return request({
      url: '/admin/edu/teacher/save',
      method: 'POST',
      data: teacher
    })
  },
  // 4.批量删除讲师
  batchRemove(ids) { // ids为id的数组
    return request({
      url: `/admin/edu/teacher/batchDel`,
      method: 'DELETE',
      data: ids
    })
  },

  // 3.删除指定讲师
  remove(id) {
    return request({
      url: `/admin/edu/teacher/deleteById/${id}`,
      method: 'DELETE'
    })
  },

  // 2.查询讲师分页数据
  teacherPage(pageNum, pageSize, searchObj) {
    return request({
      url: `admin/edu/teacher/list/${pageNum}/${pageSize}`,
      method: 'GET',
      params: searchObj // get方式以请求参数的形式提交参数
    })
  },

  // 1.查询所有讲师
  teacherList() {
    return request({
      url: 'admin/edu/teacher/list',
      method: 'get'
    })
  }
}
